package com.nf.dao;

import com.nf.entity.Studnets;
import java.util.List;
import java.sql.Connection;
import java.sql.DriverManager;


public class StudnetDaolmpl implements StudnetDao {
    public List<Studnets> getStudnetsAll() {
        return null;
    }
    private static final String DRIVER_CLASS = "com.mysql.cj.jdbc.Driver";
    private static final String SERVER_IP = "localhost";// 服务器IP地址
    private static final String DATABASE_NAME = "git01";// 连接到哪一个数据库
    private static final String USER_NAME = "root";// 用户名
    private static final String PASSWORD = "123456";// 密码

    public Connection getConnection() {
        Connection conn = null;
        String jdbcUrl = "jdbc:mysql://" + SERVER_IP + ":3306/" + DATABASE_NAME
                //+ "?serverTimezone=Asia/Shanghai&useSSL=true";
        + "?serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true";
        System.out.println(jdbcUrl);
        try {
            Class.forName(DRIVER_CLASS);
            conn = DriverManager.getConnection(jdbcUrl, USER_NAME, PASSWORD);
        } catch (Exception e) {
            System.out.println("获取连接时，异常" + e.getMessage());
            conn = null;
        }
        return conn;
    }




}
